#include "option_parser.hpp"
#include <stdlib.h>
#include <string>
#include <iostream>

using namespace std;
using namespace kxutil3;

OptionParser *option_parser;

Option option_list[] = {
    {"-c", "--commit", "", false, "", "commit result", ""},
    {"-o", "--online", "", false, "", "use online enviroment", ""},
    {"-f", "--force", "", false, "", "default process mode is incremental", ""},
    {"-t", "--timestamp", "", false, "", 
        "force mode need provoide timestamp", ""},
    {"", "--config_file", "", true, "", "use config file", "FILE"},
    {"", "--input", "", true, "", "input file name", ""},
    {"", "--output", "", true, "", "output file name", ""},
    {"", "--hid", "hotelid", true, "", "process hotel data", "HOTELID"},
    {"", "--rid", "roomid", true, "", "process room data", "ROOMID"}
};

int main(int argc, char** argv) {
    vector<string> others;

    option_parser = new OptionParser("\%prog args option ...");
    option_parser->AddOptions(sizeof(option_list)/sizeof(Option), option_list);
    //option_parser->DumpOptions();
    
    int ret = option_parser->ParseArgs(argc, argv, others);
    if ( ret < 0) {
        cout << "parse arguments error." << endl;
        option_parser->Help();
        return -1;
    } else if (ret ==0) {
        exit(0);
    }
    option_parser->DumpParsed();

    cout << endl;
    cout << "others: begin -----------" << endl;
    for (size_t i=0; i<others.size(); i++) {
        cout << others[i] << endl;
    }
    cout << "others: end --------" << endl;

    string value;
    value = option_parser->GetOption("force");
    cout << "get option: force=" << value  << endl;
    value = option_parser->GetOption("force2");
    cout << "get option: force2=" << value  << endl;

    return 0;
}
